package com.room.service;

import com.room.mapper.ClassesMapper;
import com.room.pojo.Classes;
import com.room.pojo.Student;
import com.room.pojo.Teachaer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @创建人 lin
 * @创建时间 2019/10/6
 * @描述
 */
@Service
public class ClassesService {
    @Autowired
    ClassesMapper classesMapper;

    //返回所有菜单的下拉班级初始化数据
    public List<Classes> getAllClasses(){
        return classesMapper.getAllClasses();
    }

    //根据分页获取班级数据
    public List<Classes> getClassesByPage(Integer page, Integer size){
        int start  = (page-1)* size;
        return classesMapper.getClassesByPage(start,size);
    }

    public long getTotal(){
        return classesMapper.getTotal();
    }

    //根据传进的id删除学生数据
    public boolean deleteClassesById(String ids){
        String[] split = ids.split(",");
         return classesMapper.deleteClassesById(split)==split.length;
    }

    //修改班级数据
    public int updateClass(Classes classes){
        return classesMapper.updateByPrimaryKey(classes);
    }

    //添加学生
    public int insertClases(Classes classes){
        return classesMapper.insert(classes);
    }

    //获取最大编号
    public String getMaxId(){
        return classesMapper.getMaxId();
    }
}
